﻿using Mengsk.ProxyDelivery.App.UI.Operator;
using Mengsk.ProxyDelivery.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Mengsk.ProxyDelivery.App.UI.Config
{
    /// <summary>
    /// WeightDeviceConfig.xaml 的交互逻辑
    /// </summary>
    public partial class OperatorUserControl : UserControl, IPlugin
    {
        private WarehouseService warehouseService = ServiceContainer.GetService<WarehouseService>();

        public OperatorUserControl()
        {
            InitializeComponent();
        }

        public string Title
        {
            get { return "我的信息"; }
        }

        public Control UIControl
        {
            get { return this; }
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                this.tbNumber.Text = App.LoginOperator.Number;
                this.tbName.Text = App.LoginOperator.Name;
                this.tbPhone.Text = App.LoginOperator.Phone;
                this.tbCreateTime.Text = App.LoginOperator.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
                var item = this.warehouseService.GetById(App.LoginOperator.Warehouse);
                this.tbWarehouse.Text = item.Name;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnResetPassword_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                new ResetPasswordWindow { Operator = App.LoginOperator }.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


    }
}
